[script]
n0=;
n1=;     this section deals with all ctcps except XDCC
n2=;
n3=alias soundctcp {
n4=  if (%sctcp = ding) ding
n5=  elseif (%sctcp = speak) speak $1-
n6=  elseif (%sctcp != none) splay %sctcp
n7=}
n8=alias ctcpalert {
n9=  if $2 = send soundctcp $1 tried to dcc send you a file
n10=  elseif $2 = chat soundctcp $1 tried to dcc chat with you
n11=  else soundctcp ctcp $2- received from $1
n12=}
n13=alias replyall {
n14=  %i = 0
n15=  :nx
n16=  inc %i
n17=  if $chan(%i) != $null {
n18=    reply $chan(%i) $1-
n19=    goto nx
n20=  }
n21=}
n22=alias tempignore {
n23=  ; temp ignore that doesn't echo to status window
n24=  if $mask($1,3) !iswm %myadr { .ignore -t $mask($1,3) | .timer 1 10 .ignore -r $mask($1,3) }
n25=}
n26=alias playsound {
n27=  if (%askforfile) {
n28=    if ($findfile($wavedir,$2,1) = $null) {
n29=      if ($comchan($1,0) != 0) {
n30=        if (%autoget) {
n31=          set %tvget [ $+ [ $1 ] ] $true | set %tvfile [ $+ [ $2 ] ] $true
n32=          .timer 1 60 unset %tvget [ $+ [ $1 ] ]
n33=          .timer 1 60 unset %tvfile [ $+ [ $1 ] ]
n34=        }
n35=        msg $comchan($1,1) ! $+ $1 $2
n36=      }
n37=    }
n38=  }
n39=  else {
n40=    if ($findfile($wavedir,$2,1) = $null) altech -s %dis10 $+ (you don't have $2 $+ !)
n41=    else splay $2
n42=  }
n43=}
n44=alias gotvote {
n45=  ; received vote of $1 (yes/no) from nick $2 site $3
n46=  if $2 = $me goto placevote
n47=  elseif %votetype = 0 goto placevote
n48=  elseif %votetype = 1 {
n49=    if $2 isop %votechan goto placevote
n50=    else raw -q notice $2 :Sorry, this vote is only for those currently opped
n51=  }
n52=  elseif %votetype = 2 {
n53=    if ($isop($2,%votechan)) goto placevote
n54=    else raw -q notice $2 :Sorry, this vote is only for those in my op list
n55=  }
n56=  elseif %votetype = 3 {
n57=    if ($isop($2,%votechan)) || ($nick isop %votechan)) goto placevote
n58=    else raw -q notice $2 :Sorry, this vote is only for those currenly opped or in my op list
n59=  }
n60=  halt
n61=  :placevote
n62=  if (%voted [ $+ [ $3 ] ] ) { raw -q notice $2 :Hey! You already placed your vote! | halt }
n63=  if $1 isin yesno {
n64=    raw -q notice $2 :Your vote of " $+ $1 $+ " has been recorded.  Thanks!
n65=    altech -s %dis10 $+ Vote received from $nick
n66=    set %voted [ $+ [ $3 ] ] $true
n67=    if $1 = yes inc %voteyes
n68=    else inc %voteno
n69=  }
n70=  else raw -q notice $2 :huh? /CTCP $me YES or NO
n71=}
n72=alias gotctcp {
n73=  set %udsite $mask($2,3) | set %site $mask($2,2)
n74=  altech %dis33 $+ ( $+ %udsite $+ )
n75=  inc %ctcp [ $+ [ %site ] ] | inc %ctcp [ $+ [ %udsite ] ] | inc %ctcptotal
n76=  if %ctcp [ $+ [ %site ] ] = 1 swho $replace(%site,*!*@,*)
n77=  altech %dis34 $+ Offense %ctcp [ $+ [ %site ] ] for %site
n78=  .timer 1 30 unset %ctcp [ $+ [ %udsite ] ] | .timer 1 10 unset %ctcptotal
n79=  .timer 1 60 unset %ctcp [ $+ [ %site ] ] 
n80=  if %ctcptotal > 5 { 
n81=    .ignore -t *!*@* | .timer 1 60 .ignore -r *!*@*
n82=    altech -a %dis10 $+ CTCP Flood detected from multiple addresses!
n83=    altech -a %dis10 $+ Little Star is ignoring all CTCPs for 60 seconds
n84=    dh
n85=  }
n86=  if (%ctcp [ $+ [ %udsite ] ] > 3) {
n87=    altech -a %dis10 $+ Flood attempt detected from multiple usernames from same domain, placing domain ban on $mask($2,4)
n88=    kball $mask($2,4) Excessive CTCP's detected by you!
n89=  }  
n90=  if (%ctcp [ $+ [ %site ] ] > 2) {
n91=    if (%hbanned [ $+ [ %udsite ] ] ) halt
n92=    set %hbanned [ $+ [ %udsite ] ] $true
n93=    .timer 1 120 unset %hbanned [ $+ [ %udsite ] ]
n94=    altech -a %dis10 $+ Excessive CTCP's detected from %site
n95=    if (%dontkick = $false) {
n96=      altech -a %dis10 $+ Banning %site and %udsite and checking channel(s) for matches
n97=      modeall +bb %site %udsite
n98=      %c = 0
n99=      :nx
n100=      inc %c
n101=      if $chan(%c) != $null {
n102=        if ($me isop $chan(%c)) {
n103=          kickall %site $chan(%c) Excessive CTCP's detected by you!
n104=          kickall %udsite $chan(%c) Excessive CTCP's detected by you!
n105=        }
n106=        goto nx
n107=      }
n108=    }
n109=    if (%permignore) { .ignore -tcpni %udsite | altech -a %dis10 $+ Added %udsite to permanent ignore list }
n110=    else altech -a 3Perm Ignore Flooders disabled; did not add to permanent ignore list
n111=    if (%permban) addban %udsite global Flooder $realtime $adate
n112=    else altech -a 3Perm Ban Flooders disabled; did not add to permanent ban list
n113=    replyall flood_alert Excessive ctcp's detected from %site
n114=    if (%sflood = ding) ding
n115=    elseif (%sflood = speak) speak CTCP flood detected
n116=    elseif (%sflood != none) splay %sflood
n117=  }
n118=  halt
n119=}
n120=ctcp 1:DCC RESUME: :>
n121=ctcp 1:DCC ACCEPT: :>
n122=ctcp 1:PONG: :>
n123=ctcp 70:PONG:halt
n124=#page off
n125=ctcp 1:PAGE:{
n126=  if (($nick != $me) && ($wildsite !iswm %myadr)) tempignore $fulladdress
n127=  raw -q PRIVMSG $nick :12,0 +$ $realtime $adate 2,0I have received your page... | splay page.wav
n128=  altech -a %dis10 $+ $realtime $adate You have been paged by $fulladdress
n129=  .timer 1 3 raw -q PRIVMSG $nick :2,0If I do not reply soon, I am probably unreachable.  If so, leave a message in this window which will be saved.
n130=}
n131=#page end
n132=ctcp 1:YES:{
n133=  if $ulevel < 19 tempignore $fulladdress
n134=  if (($nick ison %votechan) && (%vote)) gotvote yes $nick $site
n135=  else gotctcp $nick $fulladdress
n136=  halt
n137=}
n138=ctcp 1:NO:{
n139=  if $ulevel < 19 tempignore $fulladdress
n140=  if (($nick ison %votechan) && (%vote)) gotvote no $nick $site
n141=  else gotctcp $nick $fulladdress
n142=  halt
n143=}
n144=ctcp 1:SOUND:{
n145=  altech %dis11 $+ [[ $+ $nick $+ ]] SOUND $2-
n146=  if ((%notbys = $false) && ($ulevel < 19)) {
n147=    inc %sounds [ $+ [ $site ] ]
n148=    .timer 1 %soundin unset %sounds [ $+ [ $site ] ]
n149=    if (%sounds [ $+ [ $site ] ] > %soundis) {
n150=      altech %dis11 $+ [[ $+ $nick $+ ]] SOUND $2-
n151=      if $comchan($nick,0) != 0 {
n152=        kball $wildsite Excessive Sound requests detected from you!
n153=        if (%ekick) {
n154=          if (%speak1) speak excessive sound requests from $nick
n155=          altech -a %dis3 $+ Excessive sound requests! %dis4 Kicking $nick
n156=        }
n157=      }
n158=      .ignore -t $wildsite | .timer 1 30 .ignore -r $wildsite
n159=      halt
n160=    }
n161=  }
n162=  if ((%allsound) || ((%ulsound) && ($ulevel > 18))) playsound $nick $2
n163=  else {
n164=    if $ulevel < 19 tempignore $fulladdress
n165=    if (%notbys = $false) ctcpalert $nick sound
n166=  }
n167=  halt
n168=}
n169=ctcp 1:DCC CHAT:{
n170=  if (($away) && (%nochataway)) {
n171=    raw -q PRIVMSG $nick :2,0Sorry, I am away right now 12,0( $+ %amsg $+ )
n172=    if (%awaylog) raw -q PRIVMSG $nick :2,0You can send me a regular /msg, which will be saved
n173=    tempignore $fulladdress
n174=    halt
n175=  }
n176=  elseif ($ulevel < 19) {
n177=    if (%uchatauto) { .creq auto | :> }
n178=    elseif (%uchatask) { .creq ask | :> }
n179=    else {
n180=      tempignore $fulladdress
n181=      raw -q notice $nick :Sorry, I am not accepting any DCC chats from unrecognized addresses right now.  Try using /query or /msg.
n182=      echo -s %dis31 $+ -Refusing DCC Chat- %dis32 $+ from $nick (un-recognized)
n183=      ctcpalert $nick chat | gotctcp $nick $fulladdress | halt
n184=    }
n185=  }
n186=  elseif ($ulevel = 70) { .creq auto | :> }
n187=  elseif (%rchatauto) { .creq auto | :> }
n188=  elseif (%rchatask) { .creq ask | :> }
n189=  else {
n190=    tempignore $fulladdress
n191=    raw -q notice $nick :Sorry, I am not accepting and DCC chats from anyone right now.  Try using /query or /msg.
n192=    echo -s %dis31 $+ -Refusing DCC Chat- %dis32 $+ from $nick ( $+ $mask($fulladdress,3) $+ ) (recognized)
n193=    ctcpalert $nick chat | halt
n194=  }
n195=}
n196=ctcp 1:DCC SEND:{
n197=  if ((%tvget [ $+ [ $nick ] ] ) && (%tvfile [ $+ [ $3 ] ] )) {
n198=    set %tvgot [ $+ [ $3 ] ] $true | .sreq +m | .sreq auto | :>
n199=  }
n200=  elseif ($fserv($nick) = $null) {
n201=    if (%minsend) .sreq +m
n202=    else .sreq -m
n203=    if $ulevel < 19 {  
n204=      if (%usendauto) { .sreq auto | raw -q notice $nick : $+ %fsend | :> }
n205=      elseif (%usendask) { .sreq ask | :> }
n206=      else {
n207=        tempignore $fulladdress
n208=        raw -q notice $nick :Sorry, I am not accepting and DCC sends from unrecognized addresses right now
n209=        echo -s %dis31 $+ -Refusing DCC Send- %dis32 $+ from $nick (un-recognized)
n210=        ctcpalert $nick send | gotctcp $nick $fulladdress | halt
n211=      }
n212=    }
n213=    else {
n214=      if (%rsendauto) { .sreq auto | raw -q notice $nick : $+ %fsend | :> }
n215=      elseif (%rsendask) { .sreq ask | :> }
n216=      else {
n217=        tempignore $fulladdress
n218=        raw -q notice $nick :Sorry, I am not accepting any DCC sends from anyone right now
n219=        echo -s %dis31 $+ -Refusing DCC Send- %dis32 $+ from $nick ( $+ $mask($fulladdress,3) $+ ) (recognized)
n220=        ctcpalert $nick send | halt
n221=      }
n222=    }
n223=  }
n224=  else {
n225=    if ((%fsask) || (%fsauto)) {
n226=      if (%fservcheck) {
n227=        set %find $findfile(c:\,$3,1)
n228=        if %find = $null set %find $findfile(d:\,$3,1)
n229=        if ((%find != $null) && ($lof(%find) >= $6)) { msg =$nick 4Refusing file:3 $3 (already have it!) | halt }
n230=      }
n231=      if (%minfs) .sreq +m
n232=      else .sreq -m
n233=      if (%fsask) { msg =$nick 4,0Send acknowledged:3,0 $3 | .sreq ask | :> }
n234=      else { msg =$nick 4,0Accepting file:3,0 $3 | .sreq auto | :> }
n235=    }
n236=    else {
n237=      tempignore $fulladdress
n238=      raw -q notice $nick :Sorry, I am not accepting DCC sends from people in f-serve right now
n239=      echo -s %dis31 $+ -Refusing DCC Send- %dis32 $+ from $nick (refusing send from people in f-serve)
n240=      halt
n241=    }
n242=  }
n243=}
n244=ctcp 1:VERSION:{
n245=  altech %dis11 $+ [[ $+ $nick $+ ]] VERSION
n246=  tempignore $fulladdress
n247=  ctcpalert $nick version | reply $nick VERSION %ver
n248=  if $ulevel < 19 gotctcp $nick $fulladdress
n249=  ; hey, I don't put the script name anywhere but here...
n250=  ; be nice and leave it alone :)
n251=  halt
n252=}
n253=ctcp 1:TIME:{
n254=  tempignore $fulladdress | ctcpalert $nick time
n255=  if $ulevel < 19 { altech %dis11 $+ [[ $+ $nick $+ ]] $1- (ignoring) | reply $nick TIME Time for me to ignore you | gotctcp $nick $fulladdress }
n256=  else { altech %dis11 $+ [[ $+ $nick $+ ]] $1 (recognized) | reply $nick TIME The time is $realtime $+ , $day $adate }
n257=  halt
n258=}
n259=ctcp 1:CLIENTINFO:{
n260=  tempignore $fulladdress | ctcpalert $nick client info
n261=  if $ulevel < 19 { altech %dis11 $+ [[ $+ $nick $+ ]] $1- (ignoring) | reply $nick won't %wont | gotctcp $nick $fulladdress }
n262=  else { altech %dis11 $+ [[ $+ $nick $+ ]] $1- (recognized) | reply $nick doesn't to this ctcp }
n263=  halt
n264=}
n265=ctcp 1:FINGER:{
n266=  tempignore $fulladdress | ctcpalert $nick finger
n267=  if $ulevel < 19 { altech %dis11 $+ [[ $+ $nick $+ ]] $1- (ignoring) | reply $nick won't %wont | gotctcp $nick $fulladdress }
n268=  else { altech %dis11 $+ [[ $+ $nick $+ ]] $1- (recognized) | reply $nick doesn't to this ctcp }
n269=  halt
n270=}
n271=ctcp 1:USERINFO:{
n272=  tempignore $fulladdress | ctcpalert $nick user info
n273=  if $ulevel < 19 { altech %dis11 $+ [[ $+ $nick $+ ]] $1- (ignoring) | reply $nick won't %wont | gotctcp $nick $fulladdress }
n274=  else { altech %dis11 $+ [[ $+ $nick $+ ]] $1- (recognized) | reply $nick doesn't to this ctcp }
n275=  halt
n276=}
n277=ctcp 1:PING:{
n278=  altech %dis11 $+ [[ $+ $nick $+ ]] $1
n279=  tempignore $fulladdress | ctcpalert $nick ping
n280=  reply $nick PING $2
n281=  if $ulevel < 19 gotctcp $nick $fulladdress
n282=  halt
n283=}
n284=ctcp 19:ISIT:{
n285=  tempignore $fulladdress
n286=  if $2 = $null { altech %dis11 $+ [[ $+ $nick $+ ]] $1 (no nick given!) | halt }
n287=  altech %dis11 $+ [[ $+ $nick $+ ]] $1-
n288=  if $2 = $me { raw -q notice $nick :uh, yeah...  I think I am who I am | halt }
n289=  if $2 = $nick { raw -q notice $nick :ummm... you doubt who you are? | halt }
n290=  if $comchan($2,0) = 0 raw -q notice $nick :I do not see $2 on any channels I am on
n291=  elseif $gl($2) < 19 raw -q notice $nick : $+ $2 is not recognized
n292=  else {
n293=    set %nick $rnick.nick($2)
n294=    if %nick = $2 raw -q notice $nick : $+ $2 ( $+ $ma($2) $+ ) is a recognized nick
n295=    else raw -q notice $nick : $+ $2 ( $+ $ma($2) $+ ) is recognized as %nick
n296=  }
n297=  halt
n298=}
n299=ctcp 19:COUNTRY:{
n300=  tempignore $fulladdress
n301=  if $2 = $null { altech %dis11 $+ [[ $+ $nick $+ ]] $1 (no nick given!) | halt }
n302=  altech %dis11 $+ [[ $+ $nick $+ ]] $1- (responding)
n303=  if $comchan($2,0) = 0 { raw -q notice $nick :I do not see $2 on any channels I am on | halt }
n304=  set %country $country($2)
n305=  if %country = $null raw -q notice $nick :I do not know where $a5($2) is!
n306=  else raw -q notice $nick : $+ $a5($2) appears to be in %country
n307=  halt
n308=}
n309=ctcp 20:HELP:{
n310=  altech %dis11 $+ [[ $+ $nick $+ ]] $1
n311=  echo 3 -s HELP information being sent to $nick
n312=  set %tn3 $nick | play -ctfriend $me $mircdirhelp\msghelp.hlp 2000
n313=  halt
n314=}
n315=ctcp 40:HELP:{
n316=  altech %dis11 $+ [[ $+ $nick $+ ]] $1
n317=  echo 3 -s HELP information being sent to $nick
n318=  set %tn3 $nick | play -ctop $me $mircdirhelp\msghelp.hlp 2000
n319=  halt
n320=}
n321=ctcp 50:HELP:{
n322=  altech %dis11 $+ [[ $+ $nick $+ ]] $1
n323=  echo 3 -s HELP information being sent to $nick
n324=  set %tn3 $nick | play -ctmaster $me $mircdirhelp\msghelp.hlp 2000
n325=  halt
n326=}
n327=alias country {
n328=  set %r2 $right( [ $a5($1) ] ,2) | set %r3 $right( [ $a5($1) ] ,3)
n329=  if %r3 = edu return the USA (at an educational institution)
n330=  elseif %r3 = gov return the USA (at a government institution)
n331=  elseif %r3 = mil return the USA (military address)
n332=  elseif ((%r3 = org) || (%r3 = net) || (%r3 = com)) return the USA
n333=  elseif %r2 = am return Armenia
n334=  elseif %r2 = ar return Argentina
n335=  elseif %r2 = at return Austria
n336=  elseif %r2 = au return Australia
n337=  elseif %r2 = be return Belgium
n338=  elseif %r2 = bm return Bermuda
n339=  elseif %r2 = br return Brazil
n340=  elseif %r2 = ca return Canada
n341=  elseif %r2 = ch return Switzerland
n342=  elseif %r2 = cl return Chile
n343=  elseif %r2 = cn return China
n344=  elseif %r2 = co return Colombia
n345=  elseif %r2 = cr return Costa Rica
n346=  elseif %r2 = cz return Czech Republic
n347=  elseif %r2 = de return Germany
n348=  elseif %r2 = dk return Denmark
n349=  elseif %r2 = ec return Ecuador
n350=  elseif %r2 = ee return Estonia
n351=  elseif %r2 = eg return Egypt
n352=  elseif %r2 = es return Spain
n353=  elseif %r2 = fi return Finland
n354=  elseif %r2 = fr return France
n355=  elseif %r2 = gb return Great Britain
n356=  elseif %r2 = gr return Greece
n357=  elseif %r2 = hk return Hong Kong
n358=  elseif %r2 = hr return Croatia
n359=  elseif %r2 = hu return Hungary
n360=  elseif %r2 = id return Indonesia
n361=  elseif %r2 = ie return Ireland
n362=  elseif %r2 = il return Israel
n363=  elseif %r2 = in return India
n364=  elseif %r2 = is return Iceland
n365=  elseif %r2 = it return Italy
n366=  elseif %r2 = jm return Jamaica
n367=  elseif %r2 = jp return Japan
n368=  elseif %r2 = kr return Korea
n369=  elseif %r2 = kw return Kuwait
n370=  elseif %r2 = lt return Lithuania
n371=  elseif %r2 = lv return Latvia
n372=  elseif %r2 = mx return Mexico
n373=  elseif %r2 = my return Malaysia
n374=  elseif %r2 = nl return the Netherlands
n375=  elseif %r2 = no return Norway
n376=  elseif %r2 = nz return New Zealand
n377=  elseif %r2 = pe return Peru
n378=  elseif %r2 = ph return Philippines
n379=  elseif %r2 = pl return Poland
n380=  elseif %r2 = pt return Portugal
n381=  elseif %r2 = ru return Russia
n382=  elseif %r2 = se return Sweden
n383=  elseif %r2 = sg return Singapore
n384=  elseif %r2 = si return Slovenia
n385=  elseif %r2 = sk return Slovakia
n386=  elseif %r2 = su return Soviet Union[sic]
n387=  elseif %r2 = th return Thailand
n388=  elseif %r2 = tr return Turkey
n389=  elseif %r2 = tw return Taiwan
n390=  elseif %r2 = uk return the United Kingdom
n391=  elseif %r2 = us return the USA
n392=  elseif %r2 = uy return Uruguay
n393=  elseif %r2 = ve return Venezuela
n394=  elseif %r2 = za return South Africa
n395=}
